function [breakEven aircraftOut]=calculateBreakEven(aircraftIn, designIn, companyIn, engineIn)
% Function that calculates break even point
%
% INPUT:
%   aircraftIn [struct aircraft]
%
% OUTPUT:
%   breakEven [int]
%   aircraftOut [struct aircraft]
%       -breakEven [int]
%
% LIMITATIONS/RESTRICTIONS:
%   Break even must be lower than 1e6.
%   Aircraft price must be defined previously.
%
% AUTHOR: Pietro A R Cerchiari
% REVISION:1.0

%% Parameters
limit=1e6;

%% Inicialisations
temp=aircraftIn;
temp.nbAircrafts=1;

%% Calculations
while calculateManufacturingCost(temp, designIn, companyIn, engineIn)>temp.price
     temp.nbAircrafts=temp.nbAircrafts+1;
    if temp.nbAircrafts>limit
        error('Break even does not exist or is greater than defined limit.');
    end
 end
%% Export data
breakEven=temp.nbAircrafts;
aircraftOut=aircraftIn;
aircraftOut.breakEven=breakEven;